﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using XDL.Framework.Screens;
using XDL.Framework;

namespace JumpNFight.Screens
{
    class GameOverPopup : XDL.Framework.Screens.DialogBoxScreen
    {
        public GameOverPopup()
        {
            // displays on top of the main game screen
            IsPopup = true;

            TransitionOnTime = TimeSpan.FromSeconds(0.25f);
            TransitionOffTime = TimeSpan.FromSeconds(0.25f);
            TextColor = Color.White;

            TextBlock titleItem = new TextBlock("GAME OVER");
            titleItem.TextAlignment = TextElement.TextAlign.Center;
            titleItem.FontName = "Fonts/TitleHeader";
            titleItem.Scale = 2;
            Controls.Add(titleItem);
            Separator separatorItem = new Separator("Separator");
            Controls.Add(separatorItem);

            Simulation.World world = GameServices.GetService<Simulation.World>();
            TextBlock crateCount = new TextBlock(string.Format("Got: {0} crate(s)", world.CrateScore));
            crateCount.Scale = 2;
            crateCount.FontName = "Fonts/Message";
            Controls.Add(crateCount);
            // TODO: add some more details on the victory (score, achievement, ...)
            TextBlock msgItem = new TextBlock("New weapon at 20 crates");
            msgItem.Scale = 2;
            msgItem.FontName = "Fonts/Message";
            Controls.Add(msgItem);

            Separator smallSep = new Separator("Separator");
            Controls.Add(smallSep);
            
            MenuItem okItem = new MenuItem("Restart");
            okItem.Scale = 2;
            okItem.TextAlignment = TextElement.TextAlign.Right;
            okItem.Selected += (o, e) => { ExitScreen(true); };
            Controls.Add(okItem);

            MenuItem exitToMenu = new MenuItem("Exit To Menu");
            exitToMenu.Scale = 2;
            exitToMenu.TextAlignment = TextElement.TextAlign.Right;
            exitToMenu.Selected += (o, e) => { ExitScreen(false); };
            Controls.Add(exitToMenu);
        }
    }
}
